<?php
include 'checkLogin.php';

include_once 'db/li.php';

@$types = dbSelectAll('select id,name from type order by id asc');
?>
<!DOCTYPE html>
<html>
	<head>
      <title>添加商品</title>
	  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="UTF-8" >
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <script src="bootstrap/js/jquery-1.11.1.min.js"></script>
      <script src="bootstrap/js/bootstrap.min.js"></script>
      <!--[if lt IE 9]>
         <script src="bootstrap/js/html5shiv.js"></script>
         <script src="bootstrap/js/respond.min.js"></script>
      <![endif]-->
      <script src="db/dialog.js"></script>
      <script src="db/loginOut.js"></script>
      <style></style>
      <script>
		$(function(){
			var mes = "<?php @print($mes);?>";
			if(mes == "添加商品成功"){
				messageDialog('消息提示','添加商品成功');
				$('#mesConfirm').click(function(){
					location.href = 'goodsList.php';
				});
			}
		});
      </script>
   	</head>
	<body>
   		<nav class='navbar' style="background:#ddd0dd;">
   			<div class='container'>
   				<div class='navbar-header'>
   					<a class='navbar-brand' href='index.php'>XX超市</a>
   				</div>
   				<div class='collapse navbar-collapse' id="bs-example-navbar-collapse-1">
   					<ul class='nav navbar-nav'>
   						<li class='dropdown'>
   							<a href='#' class='dropdown-toggle' data-toggle='dropdown'>商品管理<span class='caret'></span></a>
   							<ul class='dropdown-menu'>
   								<li><a href='goodsList.php'>所有商品</a></li>
   								<li><a href='addGoods.php'>添加商品</a></li>
   								<li><a href='#'>商品类型列表</a></li>
   								<li><a href='#'>添加商品类型</a></li>
   							</ul>
   						</li>
   						<li class='dropdown'>
   							<a href='#' class='dropdown-toggle' data-toggle='dropdown'>登录管理<span class='caret'></span></a>
   							<ul class='dropdown-menu'>
   								<li><a href='changeLogin.php' id='changeLogin'>修改登录信息</a></li>
   								<li><a href='#' id='loginOut'>退出登录</a></li>
   							</ul>
   						</li>
   					</ul>
   				</div>
   			</div>
   		</nav>
   		<div class='container'>
   			<div class='row'>
   				<div class='col-xs-2'>
   					<a href='index.php' class='btn btn-default btn-block'>返回首页</a>
   				</div>
   				<div class='col-xs-4'>
   					<div class='panel panel-primary'>
   						<div class='panel-heading'>
   							<div class='panel-title'>添加商品</div>
   						</div>
   						<form class='form-horizontal' action='addGoodsPro.php' method='post'>
   							<input type='hidden' value='goods' name='goods' />
	   						<div class='panel-body'>
	   							<?php if(!empty($mes)){?>
   									<div class='alert alert-danger'>
   										<?php @print($mes);?>
   										<div class='close' data-dismiss='alert'>&times;</div>
   									</div>
	   							<?php }?>
	   							<div class='form-group'>
	   								<label class='col-xs-3 control-label' for='name'>名称</label>
	   								<div class='col-xs-9'>
	   									<input class='form-control' name='name' id='name' type='text' placeholder='商品名称' required='required' />
	   								</div>
	   							</div>
	   							<div class='form-group'>
	   								<label class='col-xs-3 control-label' for='price'>价格</label>
	   								<div class='col-xs-9'>
	   									<input class='form-control' name='price' id='price' type='number' placeholder='商品价格' required='required' />
	   								</div>
	   							</div>
	   							<div class='form-group'>
	   								<label class='col-xs-3 control-label' for='status'>状态</label>
	   								<div class='col-xs-9'>
	   									<select class='form-control' id='status' name='status'>
	   										<option value="正常">正常</option>
	   										<option value="缺货">缺货</option>
	   									</select>
	   								</div>
	   							</div>
	   							<div class='form-group'>
	   								<label class='col-xs-3 control-label' for='typeId'>类型</label>
	   								<div class='col-xs-9'>
	   									<select class='form-control' id='typeId' name='typeId'>
	   										<option>商品类型</option>
	   										<?php foreach($types as $type){?>
	   											<option value="<?php echo $type['id'];?>"><?php echo $type['name'];?></option>
	   										<?php }?>
	   									</select>
	   								</div>
	   							</div>
	   							<div class='form-group'>
	   								<div class='col-xs-3 col-xs-offset-3'>
	   									<button class='btn btn-primary' type='submit'>添加</button>
	   								</div>
	   							</div>
	   						</div>
   						</form>
   					</div>
   				</div>
   			</div>
   		</div>
   	</body>
</html>
